package com.github.tommas.admintpl.tool;

import org.apache.shiro.crypto.hash.SimpleHash;

public class HashedPasswordGenerator {
    public static void main(String[] args) {
        String algorithm = "SHA-256";
        String username = null;
        String password = null;

        int i = 0;
        int l = args.length;
        while (i < l) {
            String arg = args[i];
            switch (arg) {
                case "-u":
                    username = args[++i];
                    break;
                case "-p":
                    password = args[++i];
                    break;
                case "-a":
                    algorithm = args[++i];
                    break;
            }
            i++;
        }

        SimpleHash hash = new SimpleHash(algorithm, password, username);
        System.out.printf("Generate hashed password: %s with username: %s and password: %s",
                hash.toHex(), username, password);
    }
}
